package Core;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class ParseMemberList {

	private List<Member> list = new ArrayList<Member>();

	@SuppressWarnings("resource")
	public List<Member> getListFromFile(File file, String codepage) throws NumberFormatException, IOException {
		BufferedReader br = null;
		String s;
//		try {
			br = new BufferedReader(new InputStreamReader(new FileInputStream(file), codepage));
			while ((s = br.readLine()) != null) {
				Member m = new Member();
				String[] attr = s.split(",");
				m.setNumber(new Integer(attr[0]));
				m.setName(attr[1] + " " + attr[2]);
				m.setCity(attr[3]);
				list.add(m);
			}
//		} catch (UnsupportedEncodingException e) {
//			e.printStackTrace();
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
		return list;
	}

}
